package com.hos.controller;




import com.hos.pojo.Card001;
import com.hos.pojo.Doctor;
import com.hos.pojo.Patient;
import com.hos.pojo.PostCard;
import com.hos.service.Card001Service;
import com.hos.service.DoctorService;
import com.hos.service.PatientService;
import com.hos.service.PostCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    DoctorService doctorService;

    @Autowired
    PostCardService postCardService;

    @Autowired
    PatientService patientService;

    @Autowired
    Card001Service card001Service;

    @GetMapping("/doctorEdit/{id}")
    public String bookEdit(@PathVariable Integer id, Model model){
        Doctor doctor = doctorService.get(id);
        model.addAttribute("doctor",doctor);

        return "doctorEdit";
    }
    @GetMapping("/cardEdit/{id}")
    public String cardEdit(@PathVariable Integer id, Model model){
        PostCard postCard = postCardService.get(id);
        model.addAttribute("card",postCard);

        return "cardEdit";
    }
    @GetMapping("/patientEdit/{id}")
    public String patientEdit(@PathVariable Integer id, Model model){
        Patient patient = patientService.get(id);
        model.addAttribute("patient",patient);
        return "patientEdit";
    }
    @GetMapping("/card001Edit/{id}")
    public String card001Edit(@PathVariable Integer id, Model model){
        System.out.println(id);
        Card001 card001 = card001Service.getById(id);
        model.addAttribute("card001",card001);
        return "card001Edit";
    }

}
